import webos
import time
import sys
import pygame
from pygame.locals import *

def main():
	print "Python meets WebOS!"
	print "-------------------"
	webos.init()
	print "Running on device: ", webos.get_hardware()
	print "Starting up PyGame"
	pygame.init();
	print "Getting screen"
	
	screen = pygame.display.set_mode()
	background_color = (255,255,255)
	while True:
		event = pygame.event.wait()
		if event.type == KEYDOWN:
			if event.key == webos.KEY_GESTURE_BACK:
				webos.vibrate(20,100)
				break
			elif event.key == K_m:
				webos.minimize()
		pygame.draw.rect(screen,background_color,screen.get_rect())
		pygame.display.flip()
		
	webos.quit()
	sys.exit(0);

if __name__ == "__main__":
    main()
